package com.scanner.regex;

import java.util.Scanner;
import java.util.regex.MatchResult;

public class Demo2 {
	
	public static void main(String[] args) {
		String s="58.27.82.161@02/10/2005 204.45.234.40@02/11/2005 58.27.82.161@02/11/2005";
		
		Scanner sc=new Scanner(s);
		String p="(\\d+[.]\\d+[.]\\d+[.]\\d+)@(\\d{2}/\\d{2}/\\d{4})";
		
		while(sc.hasNext(p)){
			sc.next(p);
			//只针对下一个输入分词进行匹配，如果你的正则表达式中含有定界符，那么就永远不可能匹配成功
			MatchResult result=sc.match();
			String ip=result.group(1);
			String date=result.group(2);
			System.out.format("Threat on %s from %s\n", date, ip);
		}
	}

}
